home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / MM2_DEV / S / MYUTIL / DECODEF.M < prev    next >
Encoding:
Text File  |  1990-04-21  |  1.9 KB  |  87 lines

  1. MODULE DecoDef;
  2.  
  3. (*
  4.  * Decodiert übersetzte Definitions-Module.
  5.  * Das gewünschte Modul wird in diesem Prg. mit dem File-Selektor ausgewählt.
  6.  *)
  7.  
  8. FROM SYSTEM IMPORT ADDRESS, BYTE;
  9. FROM GEMEnv IMPORT InitGem, RC, DeviceHandle;
  10. FROM EasyGEM1 IMPORT SelectMask, SelectFile;
  11. FROM Strings IMPORT String, Append;
  12. FROM ShellMsg IMPORT DefSfx;
  13. FROM Files IMPORT File, Open, Access, Close;
  14. FROM Binary IMPORT ReadBytes, FileSize;
  15. FROM Storage IMPORT ALLOCATE;
  16. FROM InOut IMPORT OpenInput, Read, Write, WriteLn, WriteString, WriteCard,
  17.                 WriteInt, WritePg, WriteHex, WriteLHex;
  18.  
  19. VAR defname: String;
  20.     ok: BOOLEAN;
  21.     f: File;
  22.     len: LONGCARD;
  23.     buf: ADDRESS;
  24.     devHdl: DeviceHandle;
  25.     ch: CHAR;
  26.     strptr: POINTER TO String;
  27.     c: CARDINAL;
  28.     lc: LONGCARD;
  29.     i: INTEGER;
  30.     li: LONGINT;
  31.  
  32. PROCEDURE peek (ofs: LONGCARD; VAR data: ARRAY OF BYTE);
  33.   VAR p: POINTER TO BYTE; n: CARDINAL;
  34.   BEGIN
  35.     p:= buf + ofs;
  36.     FOR n:= 0 TO HIGH (data) DO
  37.       data [n]:= p^;
  38.       INC (p)
  39.     END;
  40.   END peek;
  41.   
  42. BEGIN
  43.   InitGem (RC, devHdl, ok);
  44.   IF ~ok THEN HALT END;
  45.   
  46.   (*
  47.    * Def-Datei auswählen
  48.    *)
  49.   SelectMask:= '*.';
  50.   Append (DefSfx, SelectMask, ok);
  51.   defname:= '';
  52.   SelectFile ('Wähle DEF-Datei', defname, ok);
  53.   IF NOT ok THEN RETURN END;
  54.   
  55.   (*
  56.    * Datei laden
  57.    *)
  58.   Open (f, defname, readOnly);
  59.   len:= FileSize (f);
  60.   ALLOCATE (buf, len);
  61.   IF buf = NIL THEN
  62.     WriteString ('Speicher reicht nicht!');
  63.     Read (ch);
  64.     RETURN
  65.   END;
  66.   ReadBytes (f, buf, len, len);
  67.   Close (f);
  68.   
  69.   INC (buf, 8); (* Header "MM2Code" überspringen *)
  70.   
  71.   WriteString ('Modulname: ');
  72.   peek (22, strptr);
  73.   INC (strptr, LONGCARD(buf));
  74.   WriteString (strptr^);
  75.   WriteLn;
  76.   WriteLn;
  77.   
  78.   WriteString ('Key: ');
  79.   peek (4, lc);
  80.   WriteLHex (lc, 9);
  81.   WriteLn;
  82.   
  83.   WriteLn;
  84.   WriteString ('Taste...');
  85.   Read (ch)
  86. END DecoDef.
  87.